package jumpingnotes.model;

import java.io.Serializable;

public class Result implements Serializable
{
	private static final long serialVersionUID = -840122773460797502L;
	
	private int returnCode;
	private String errorMessage;
	private Object returnObj;

	public Result(int returnCode, String errorMessage, Object returnObj)
	{
		this.returnCode = returnCode;
		this.errorMessage = errorMessage;
		this.returnObj = returnObj;
	}

	public Result(int errorCode)
	{
		this.returnCode = errorCode;
		this.errorMessage = ErrorType.getErrorMessage(errorCode);
		this.returnObj = null;
	}

	public Result(Object returnObj)
	{
		this.returnCode = ErrorType.NO_ERROR;
		this.errorMessage = null;
		this.returnObj = returnObj;
	}

	public Result()
	{
		this.returnCode = ErrorType.NO_ERROR;
		this.errorMessage = null;
		this.returnObj = null;
	}

	public String getErrorMessage()
	{
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage)
	{
		this.errorMessage = errorMessage;
	}

	public int getReturnCode()
	{
		return returnCode;
	}

	public void setReturnCode(int returnCode)
	{
		this.returnCode = returnCode;
	}

	public Object getReturnObj()
	{
		return returnObj;
	}

	public void setReturnObj(Object returnObj)
	{
		this.returnObj = returnObj;
	}
	
	public boolean isSuccess()
	{
		if (returnCode == ErrorType.NO_ERROR)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}
